package org.example.ecommerce_system.mapper;

import org.apache.ibatis.annotations.*;
import org.example.ecommerce_system.entity.Order;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Select("select * from `order`")
    List<Order> getAllOrder();

    @Select("select * from `order` where userName like concat('%', #{userName},'%')")
    List<Order> searchName(String userName);

    @Select("select * from `order` where userName like concat('%', #{userName},'%') and proName like concat('%', #{proName},'%')")
    List<Order> searchCombin(String userName,String proName);

    @Delete("delete from `order` where id=#{id}")
    int deleteOrder(int id);

    @Insert("insert into `order` values (null,#{userName},#{proName},#{number},#{sumPrice})")
    int insertOrder(Order order);

    @Update("update `order` set userName=#{userName},proName=#{proName},number=#{number},sumPrice=#{sumPrice} where id=#{id}")
    int updateOrder(Order order);
}
